package handlers

import (
	"github.com/gin-gonic/gin"
	"github.com/yourusername/virt-manager-go/internal/service"
)

// getConnectionFromRequest gets the connection from the 'connection' query parameter
func getConnectionFromRequest(c *gin.Context, connMgr *service.ConnectionManager) (*service.Connection, error) {
	connID := c.Query("connection")
	if connID == "" {
		// Fallback to default connection if no connection query parameter
		return connMgr.GetDefaultConnection()
	}
	return connMgr.GetConnection(connID)
}
